06/10/26/ssl modes#2874
Draft
chernser wants to merge 4 commits into
Draft
Conversation
|
Repository collaborators can run the JMH benchmark suite against this PR by commenting: Optional regression threshold override (Δ% on Time or Alloc/op; defaults to 10%): Only one benchmark run per PR is active at a time — issuing a new |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
SSL Modes
V1 historically has
ssl_modeparameter with two options (NONEandSTRICT). WhenNONEis selected then SSL encryption is used but no identityverification is done (what is conter-intuitive). When
STRICTis used then full verification is done. Last option is just placeholder for default behaviorwhich is full verification.
Usually JDBC drivers provide more options to verify identity and server certificate.This is important to support in ClickHouse Java and JDBC because
many modern systems not always use strict verification. For example, k8s environment can use self-signed certificates per host. This means that
custom CA certification is needed. In other scenarios there could be only custom certificate for multiple endpoints and identity verification should be skipped.
Client V2 should support next values for
ssl_mode:Disabled- disabled encryption and verification. This option cannot be used with HTTP(s) interface because protocol itself defines usage of SSL.This option will be used for TCP protocol because usage of SSL defined by client.
Trust- trusts server certificate and do not validates identity against certificate. Traffic is encrypted.VerifyCa- verifies server certificate (it should be sugned by trusted CA) but skips identity verification (doesn't check hostname matches ceriticate).This used when one SSL certificate for multiple hosts. Traffic is encrypted.
Strict- default behavior when server certificate is verified fully. This classic connection to ClickHouse cloud.JDBC V2 should support next values for
ssl_mode:none- for backward compatibility only. This option is alias totruston client side.disabled- same as client v2trust- same as client v2verify-ca- same as client v2strict- same as client v2Certificate Authority Verification
Certificate should be signed by trusted CA. JVM trusts all ceriticates that are signed by CA from default truststore. However adding
certificate to each JVM truststore can be problematic and insecure (because all parts of application running on the JVM become
accepting custom CA what can be used by attackers). Thus client library provide way to specify custom truststore only for its communication.
Truststore is a file and not always suitable so client can accept root certificate as string.
Identity Verification
Server hostname should match certificate it provides on connection. When same certificte is issues for multiple server endpoint then this verification
will fail. Thus there is option
verify-ca.Code Changes
Preparation
com.clickhouse.client.api.internal.HttpAPIClientHelper#createSSLContext.Changes in Client V2
SSLModeenum with constantsDisabled,Trust,VerifyCaandStrict.SSL_MODE("ssl_mode", SSLMode.class, SSLMode.Strict)tocom.clickhouse.client.api.ClientConfigProperties. Documentation should tell about modes,how it works with different protocols and that it doesn't make client use encryption on HTTP protocol.
com.clickhouse.client.api.internal.HttpAPIClientHelper#createSSLContexthandle modes:SSLMode.Trustshould use all trust storeSSLMode.VerifyCAshould use all trust host verifier.com.clickhouse.client.api.ClientConfigProperties#CA_CERTIFICATEcorrectly and independently fromSSL_KEYandSSL_CERTIFICATEincom.clickhouse.client.api.internal.HttpAPIClientHelper#createSSLContext:SSL_KEYandSSL_CERTIFICATEare specified it mean MTL or SSL authentication is used and this should be added to ssl context.SSLMode.TrustthenClickHouseSslMode.NONEshould be passed toClickHouseDefaultSslContextProviderwhen creating context.SSLMOde.VerifyCAthen all trust host verifier should be usedcom.clickhouse.client.api.internal.HttpAPIClientHelper#createHttpClientmake handleSSLMode.TrustandSSLMode.VerifyCAby using all trust host verifier. It is similar to when SNI is used.Tests for all SSL modes should be added and be run against docker instance.
Changes in JDBC V2
ssl_modein passed properties before sending them to client builder. Make alias fromnonetotrustin this case.Tests for all SSL modes should be also added to JDBC connection tests.
Closes: #2389
Closes: #2309
Closes: #2819
Checklist
Delete items not relevant to your PR: